﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EF4.Model.Entities;
using System.Data;

namespace EF4.Repository.SQL
{
    public class ObjectBuilder
    {
        public static Product BuildProduct(IDataReader reader)
        {
            Product product = new Product();
            if (reader["Id"] != null) product.Id = Convert.ToInt32(reader["Id"]);
            if (reader["Alias"] != null) product.Alias = Convert.ToString(reader["Alias"]);
            if (reader["Id"] != null) product.CategoryId = Convert.ToInt32(reader["CategoryId"]);
            if (reader["Id"] != null) product.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]);
            if (reader["Id"] != null) product.Name = Convert.ToString(reader["Name"]);
            if (reader["Id"] != null) product.Status = Convert.ToString(reader["Status"]);
            if (reader["Id"] != null) product.UpdatedDate = Convert.ToDateTime(reader["UpdatedDate"]);

            return product;
        }
    }
}
